#include "TalkWindowItem.h"
#include "CommonUtils.h"
#include "define.h"

TalkWindowItem::TalkWindowItem(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);
	init();
}

TalkWindowItem::~TalkWindowItem()
{
}

void TalkWindowItem::init()
{
	ui.tclosebtn->setVisible(false);
	connect(ui.tclosebtn, &QPushButton::clicked, this, &TalkWindowItem::signalCloseBtnClicked);
}

/*=================================================================*/

void TalkWindowItem::setHeadPixmap(const QString & headPath)
{
	QPixmap head(headPath);
	QPixmap mask(QRC_MAIN_PNG("head_mask"));
	ui.headLabel->setPixmap(CommonUtils::getRoundedPixmap(head, mask, ui.headLabel->size()));
}

void TalkWindowItem::setMsgText(const QString & msgText)
{
	ui.msgLabel->setText(msgText);
}

/*=================================================================*/

void TalkWindowItem::enterEvent(QEvent * event)
{
	ui.tclosebtn->setVisible(true);
	return QWidget::enterEvent(event);
}

void TalkWindowItem::leaveEvent(QEvent * event)
{
	ui.tclosebtn->setVisible(false);
	return QWidget::leaveEvent(event);
}
